preexperiment_date <- "06 April 2023 10 54AM/All"
postexperiment_date <- "06 April 2023 04 02PM/All"
##--- last fish run in trial ---##
experiment_date <- "06 April 2023 12 13PM/Oxygen"
experiment_date2 <- "06 April 2023 12 13PM/All"
firesting <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19)
Cycle_1 <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE)
Cycle_last <-read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_date2,"slopes/Cycle_20.txt"), # custom
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) preexperiment_date_asus <- "06 April 2023 10 52AM/All"
postexperiment_date_asus <- "06 April 2023 05 03PM/All"
##--- last fish run in trial ---##
experiment_date_asus <- "06 April 2023 01 42PM/Oxygen"
experiment_date2_asus <- "06 April 2023 01 42PM/All"
firesting_asus <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19)
Cycle_1_asus <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE)
Cycle_last_asus <-read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date2_asus,"slopes/Cycle_20.txt"), # custom
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) chamber1_dell = 0.04650
chamber2_dell = 0.04593
chamber3_dell = 0.04977
chamber4_dell = 0.04860
chamber1_asus = 0.04565
chamber2_asus = 0.04573+0.00385
chamber3_asus = 0.04551+0.00322
chamber4_asus = 0.04791+0.00277
Date_tested="2023-04-06"
Clutch = "73"
Male = "CARL344"
Female = "CARL370"
Population = "Arlington reef"
Tank =166
salinity =36
Date_analysed = Sys.Date() Replicate = 1
mass = 0.0006799
chamber = "ch4"
Swim = "good/good"
chamber_vol = chamber4_dell
system1 = "Dell"
Notes=""
##--- time of trail ---##
experiment_mmr_date <- "06 April 2023 11 41AM/Oxygen"
experiment_mmr_date2 <- "06 April 2023 11 41AM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.000882439
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.001833171
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.82
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 19 20 21 22 23
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.82
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 20 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 14 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 1 1 180.8267 -0.01721613 0.960 NA 41 262 4858.85
## 2: 10 1 323.8851 -0.02320543 0.981 NA 4273 4504 9719.65
## 3: 13 1 361.0926 -0.02316872 0.989 NA 5748 5981 11339.06
## 4: 14 1 361.1600 -0.02211547 0.987 NA 6241 6474 11878.77
## 5: 16 1 406.5662 -0.02374727 0.990 NA 7229 7462 12958.95
## 6: 18 1 445.8453 -0.02475436 0.972 NA 8217 8451 14039.04
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 5113.58 97.013 92.163 -0.01721613 -0.0009536422 -0.01626248 -0.01626248
## 2: 9974.12 98.276 92.720 -0.02320543 -0.0014430198 -0.02176241 -0.02176241
## 3: 11594.18 97.900 92.340 -0.02316872 -0.0016060966 -0.02156263 -0.02156263
## 4: 12133.84 98.360 92.439 -0.02211547 -0.0016604327 -0.02045504 -0.02045504
## 5: 13213.80 98.446 92.578 -0.02374727 -0.0017691753 -0.02197810 -0.02197810
## 6: 14294.61 98.429 92.594 -0.02475436 -0.0018779562 -0.02287641 -0.02287641
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0486 0.0006799 NA 36 30 1.013253 -0.1759795
## 2: %Air sec 0.0486 0.0006799 NA 36 30 1.013253 -0.2354953
## 3: %Air sec 0.0486 0.0006799 NA 36 30 1.013253 -0.2333333
## 4: %Air sec 0.0486 0.0006799 NA 36 30 1.013253 -0.2213479
## 5: %Air sec 0.0486 0.0006799 NA 36 30 1.013253 -0.2378292
## 6: %Air sec 0.0486 0.0006799 NA 36 30 1.013253 -0.2475500
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -258.8314 NA mgO2/hr/kg -258.8314
## 2: -346.3675 NA mgO2/hr/kg -346.3675
## 3: -343.1877 NA mgO2/hr/kg -343.1877
## 4: -325.5595 NA mgO2/hr/kg -325.5595
## 5: -349.8003 NA mgO2/hr/kg -349.8003
## 6: -364.0977 NA mgO2/hr/kg -364.0977
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 1 | CARL344 | CARL370 | Arlington reef | 166 | 0.0006799 | ch4 | Dell | 0.0486 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 345.8025 | 0.2351111 | 0.9838 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.08 1.65
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 20 21 23 24
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.08 1.56
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 335.8394 -0.08184158 0.9829131 NA 4 57 2892.22
## 2: NA 2 335.8230 -0.08183827 0.9829183 NA 3 56 2891.00
## 3: NA 3 335.1695 -0.08161028 0.9824405 NA 5 58 2893.31
## 4: NA 4 334.8700 -0.08151442 0.9822226 NA 2 55 2889.91
## 5: NA 5 333.9194 -0.08118065 0.9815450 NA 6 59 2894.41
## ---
## 207: NA 207 176.0192 -0.02874792 0.9682135 NA 207 260 3123.77
## 208: NA 208 174.7249 -0.02833916 0.9714304 NA 208 261 3125.15
## 209: NA 209 173.7344 -0.02802687 0.9741718 NA 209 262 3126.28
## 210: NA 210 172.8019 -0.02773296 0.9765843 NA 210 263 3127.38
## 211: NA 211 172.0974 -0.02751136 0.9785409 NA 211 264 3128.46
## endtime oxy endoxy rate
## 1: 2952.22 98.993 94.400 -0.08184158
## 2: 2951.00 98.979 94.419 -0.08183827
## 3: 2953.31 98.972 94.370 -0.08161028
## 4: 2949.91 99.019 94.498 -0.08151442
## 5: 2954.41 98.931 94.351 -0.08118065
## ---
## 207: 3183.77 86.536 84.467 -0.02874792
## 208: 3185.15 86.433 84.438 -0.02833916
## 209: 3186.28 86.362 84.382 -0.02802687
## 210: 3187.38 86.301 84.362 -0.02773296
## 211: 3188.46 86.242 84.312 -0.02751136
##
## Regressions : 211 | Results : 211 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 211 adjusted rate(s):
## Rate : -0.08184158
## Adjustment : -0.000882439
## Adjusted Rate : -0.08095914
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 211 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 210 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 335.8394 -0.08184158 0.9829131 NA 4 57 2892.22
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 2952.22 98.993 94.4 -0.08184158 -0.000882439 -0.08095914 -0.08095914
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0486 0.0006799 NA 36 30 1.013253 -0.8760744
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1288.534 NA mgO2/hr/kg -1288.534
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 1 | CARL344 | CARL370 | Arlington reef | 166 | 0.0006799 | ch4 | Dell | 0.0486 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 345.8025 | 0.2351111 | 0.9838 | 1288.534 | 0.8760744 | 0.9829131 | 942.7317 | 0.6409633 |
## Rows: 244 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 2
mass = 0.0003941
chamber = "ch3"
Swim = "good/good"
chamber_vol = chamber3_dell
system1 = "Dell"
Notes=""
##--- time of trail ---##
experiment_mmr_date <- "06 April 2023 11 53AM/Oxygen"
experiment_mmr_date2 <- "06 April 2023 11 53AM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.00104377
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.001921551
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.82
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 19 20 21 22 23
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.82
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 2 rate(s) removed, 18 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 12 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 9 1 215.8858 -0.01277106 0.996 NA 3786 4015 9178.60
## 2: 12 1 241.1424 -0.01320724 0.986 NA 5255 5488 10798.92
## 3: 13 1 235.5864 -0.01206412 0.976 NA 5748 5981 11339.06
## 4: 15 1 257.4407 -0.01277487 0.995 NA 6735 6968 12419.06
## 5: 16 1 247.2461 -0.01145406 0.984 NA 7229 7462 12958.95
## 6: 20 1 274.0588 -0.01156933 0.982 NA 9205 9438 15118.98
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 9434.23 98.634 95.436 -0.01277106 -0.001511097 -0.011259963 -0.011259963
## 2: 11053.75 98.202 95.078 -0.01320724 -0.001661678 -0.011545565 -0.011545565
## 3: 11594.18 98.407 95.590 -0.01206412 -0.001711901 -0.010352216 -0.010352216
## 4: 12673.71 98.726 95.397 -0.01277487 -0.001812271 -0.010962597 -0.010962597
## 5: 13213.80 98.553 95.673 -0.01145406 -0.001862466 -0.009591592 -0.009591592
## 6: 15373.96 98.838 96.085 -0.01156933 -0.002063260 -0.009506067 -0.009506067
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04977 0.0003941 NA 36 30 1.013253 -0.1247796
## 2: %Air sec 0.04977 0.0003941 NA 36 30 1.013253 -0.1279445
## 3: %Air sec 0.04977 0.0003941 NA 36 30 1.013253 -0.1147202
## 4: %Air sec 0.04977 0.0003941 NA 36 30 1.013253 -0.1214842
## 5: %Air sec 0.04977 0.0003941 NA 36 30 1.013253 -0.1062912
## 6: %Air sec 0.04977 0.0003941 NA 36 30 1.013253 -0.1053434
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -316.6190 NA mgO2/hr/kg -316.6190
## 2: -324.6499 NA mgO2/hr/kg -324.6499
## 3: -291.0941 NA mgO2/hr/kg -291.0941
## 4: -308.2574 NA mgO2/hr/kg -308.2574
## 5: -269.7061 NA mgO2/hr/kg -269.7061
## 6: -267.3012 NA mgO2/hr/kg -267.3012
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 2 | CARL344 | CARL370 | Arlington reef | 166 | 0.0003941 | ch3 | Dell | 0.04977 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 302.0653 | 0.1190439 | 0.9874 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 1.65
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 2 3 4 7 8 9 10 11 12 13 14 15 16 17 20 22 23 24 26 27
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.08 1.36
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 295.8174 -0.05267616 0.9919646 NA 156 210 3784.19
## 2: NA 2 295.4951 -0.05259104 0.9918079 NA 157 211 3785.28
## 3: NA 3 295.3795 -0.05256218 0.9916913 NA 155 209 3783.11
## 4: NA 4 294.7839 -0.05240702 0.9912340 NA 154 208 3781.98
## 5: NA 5 294.4360 -0.05231277 0.9912227 NA 158 212 3786.44
## ---
## 211: NA 211 145.5190 -0.01296036 0.9582518 NA 64 118 3681.28
## 212: NA 212 145.4453 -0.01294046 0.9580835 NA 65 119 3682.52
## 213: NA 213 145.3931 -0.01292524 0.9591780 NA 62 116 3679.00
## 214: NA 214 145.3753 -0.01292122 0.9577257 NA 66 120 3683.62
## 215: NA 215 145.2732 -0.01289224 0.9597943 NA 61 115 3677.91
## endtime oxy endoxy rate
## 1: 3844.19 96.376 93.375 -0.05267616
## 2: 3845.28 96.393 93.356 -0.05259104
## 3: 3843.11 96.393 93.443 -0.05256218
## 4: 3841.98 96.369 93.526 -0.05240702
## 5: 3846.44 96.372 93.364 -0.05231277
## ---
## 211: 3741.28 97.865 96.991 -0.01296036
## 212: 3742.52 97.800 97.027 -0.01294046
## 213: 3739.00 97.905 96.993 -0.01292524
## 214: 3743.62 97.754 97.044 -0.01292122
## 215: 3737.91 97.922 97.076 -0.01289224
##
## Regressions : 215 | Results : 215 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 215 adjusted rate(s):
## Rate : -0.05267616
## Adjustment : -0.00104377
## Adjusted Rate : -0.05163239
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 48 rate(s) removed, 167 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 166 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 295.8174 -0.05267616 0.9919646 NA 156 210 3784.19
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 3844.19 96.376 93.375 -0.05267616 -0.00104377 -0.05163239 -0.05163239
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04977 0.0003941 NA 36 30 1.013253 -0.5721748
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1451.852 NA mgO2/hr/kg -1451.852
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 2 | CARL344 | CARL370 | Arlington reef | 166 | 0.0003941 | ch3 | Dell | 0.04977 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 302.0653 | 0.1190439 | 0.9874 | 1451.852 | 0.5721748 | 0.9919646 | 1149.787 | 0.4531309 |
## Rows: 245 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 3
mass = 0.0004895
chamber = "ch2"
Swim = "good/good"
chamber_vol = chamber2_dell
system1 = "Dell"
Notes="max reliable?"
##--- time of trail ---##
experiment_mmr_date <- "06 April 2023 12 03PM/Oxygen"
experiment_mmr_date2 <- "06 April 2023 12 03PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0003485666
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.002556856
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.82
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 19 20 21 22 23
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.82
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 1 rate(s) removed, 19 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 13 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 3 1 174.8158 -0.01301264 0.995 NA 983 1176 5938.97
## 2: 13 1 295.6796 -0.01747954 0.993 NA 5748 5981 11339.06
## 3: 17 1 343.1790 -0.01816598 0.992 NA 7723 7956 13499.13
## 4: 18 1 355.8883 -0.01836673 0.990 NA 8217 8451 14039.04
## 5: 19 1 327.9623 -0.01577830 0.990 NA 8711 8945 14578.70
## 6: 20 1 390.5254 -0.01934545 0.990 NA 9205 9438 15118.98
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 6193.47 97.489 94.217 -0.01301264 -0.0007665163 -0.01224612 -0.01224612
## 2: 11594.18 97.464 92.686 -0.01747954 -0.0020294250 -0.01545011 -0.01545011
## 3: 13753.85 97.645 93.145 -0.01816598 -0.0025345207 -0.01563146 -0.01563146
## 4: 14294.61 97.661 93.129 -0.01836673 -0.0026608806 -0.01570585 -0.01570585
## 5: 14834.37 97.785 93.687 -0.01577830 -0.0027870943 -0.01299120 -0.01299120
## 6: 15373.96 98.001 93.394 -0.01934545 -0.0029133606 -0.01643209 -0.01643209
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04593 0.0004895 NA 36 30 1.013253 -0.1252374
## 2: %Air sec 0.04593 0.0004895 NA 36 30 1.013253 -0.1580036
## 3: %Air sec 0.04593 0.0004895 NA 36 30 1.013253 -0.1598582
## 4: %Air sec 0.04593 0.0004895 NA 36 30 1.013253 -0.1606189
## 5: %Air sec 0.04593 0.0004895 NA 36 30 1.013253 -0.1328571
## 6: %Air sec 0.04593 0.0004895 NA 36 30 1.013253 -0.1680459
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -255.8475 NA mgO2/hr/kg -255.8475
## 2: -322.7857 NA mgO2/hr/kg -322.7857
## 3: -326.5745 NA mgO2/hr/kg -326.5745
## 4: -328.1285 NA mgO2/hr/kg -328.1285
## 5: -271.4138 NA mgO2/hr/kg -271.4138
## 6: -343.3011 NA mgO2/hr/kg -343.3011
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 3 | CARL344 | CARL370 | Arlington reef | 166 | 0.0004895 | ch2 | Dell | 0.04593 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 318.4407 | 0.1558767 | 0.991 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 1.65
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 8 9 10 11 13 14 15 16 17 18 19 21 22 23 24
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.08 1.37
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 289.7350 -0.04491674 0.9926559 NA 108 161 4318.50
## 2: NA 2 289.6564 -0.04489758 0.9925653 NA 109 162 4319.59
## 3: NA 3 289.3536 -0.04483007 0.9922875 NA 107 160 4317.42
## 4: NA 4 289.0474 -0.04475625 0.9917761 NA 110 163 4320.71
## 5: NA 5 288.7744 -0.04469734 0.9919786 NA 106 159 4316.24
## ---
## 209: NA 209 158.9824 -0.01520834 0.9460096 NA 203 256 4425.81
## 210: NA 210 158.2131 -0.01503934 0.9523676 NA 207 260 4430.43
## 211: NA 211 157.8857 -0.01496331 0.9526003 NA 204 257 4426.92
## 212: NA 212 157.3459 -0.01484412 0.9559368 NA 206 259 4429.35
## 213: NA 213 156.5162 -0.01465765 0.9549238 NA 205 258 4428.25
## endtime oxy endoxy rate
## 1: 4378.50 95.620 93.165 -0.04491674
## 2: 4379.59 95.572 93.152 -0.04489758
## 3: 4377.42 95.638 93.139 -0.04483007
## 4: 4380.71 95.543 93.177 -0.04475625
## 5: 4376.24 95.729 93.134 -0.04469734
## ---
## 209: 4485.81 91.858 90.688 -0.01520834
## 210: 4490.43 91.612 90.540 -0.01503934
## 211: 4486.92 91.786 90.684 -0.01496331
## 212: 4489.35 91.634 90.611 -0.01484412
## 213: 4488.25 91.729 90.625 -0.01465765
##
## Regressions : 213 | Results : 213 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 213 adjusted rate(s):
## Rate : -0.04491674
## Adjustment : -0.0003485666
## Adjusted Rate : -0.04456817
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 32 rate(s) removed, 181 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 180 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 289.735 -0.04491674 0.9926559 NA 108 161 4318.5
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 4378.5 95.62 93.165 -0.04491674 -0.0003485666 -0.04456817 -0.04456817
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04593 0.0004895 NA 36 30 1.013253 -0.4557851
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -931.1238 NA mgO2/hr/kg -931.1238
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 3 | CARL344 | CARL370 | Arlington reef | 166 | 0.0004895 | ch2 | Dell | 0.04593 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 318.4407 | 0.1558767 | 0.991 | 931.1238 | 0.4557851 | 0.9926559 | 612.6831 | 0.2999084 | max reliable? |
## Rows: 246 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 4
mass = 0.0005599
chamber = "ch1"
Swim = "good/good"
chamber_vol = chamber1_dell
system1 = "Dell"
Notes=""
##--- time of trail ---##
experiment_mmr_date <- "06 April 2023 12 13PM/Oxygen"
experiment_mmr_date2 <- "06 April 2023 12 13PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.001991113
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.002794748
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.82
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 19 20 21 22 23
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.82
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 20 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 14 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 12 1 343.4461 -0.02272894 0.994 NA 5255 5488 10798.92
## 2: 14 1 391.3902 -0.02467709 0.985 NA 6241 6474 11878.77
## 3: 16 1 442.9864 -0.02658919 0.997 NA 7229 7462 12958.95
## 4: 17 1 402.8303 -0.02250744 0.984 NA 7723 7956 13499.13
## 5: 18 1 446.7685 -0.02481419 0.998 NA 8217 8451 14039.04
## 6: 19 1 446.9132 -0.02389319 0.995 NA 8711 8945 14578.70
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 11053.75 98.133 91.796 -0.02272894 -0.002556826 -0.02017211 -0.02017211
## 2: 12133.84 98.066 91.645 -0.02467709 -0.002648736 -0.02202836 -0.02202836
## 3: 13213.80 98.227 91.894 -0.02658919 -0.002740654 -0.02384854 -0.02384854
## 4: 13753.85 98.631 92.519 -0.02250744 -0.002786620 -0.01972082 -0.01972082
## 5: 14294.61 98.251 91.967 -0.02481419 -0.002832604 -0.02198159 -0.02198159
## 6: 14834.37 98.475 92.172 -0.02389319 -0.002878536 -0.02101466 -0.02101466
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0465 0.0005599 NA 36 30 1.013253 -0.2088542
## 2: %Air sec 0.0465 0.0005599 NA 36 30 1.013253 -0.2280730
## 3: %Air sec 0.0465 0.0005599 NA 36 30 1.013253 -0.2469185
## 4: %Air sec 0.0465 0.0005599 NA 36 30 1.013253 -0.2041817
## 5: %Air sec 0.0465 0.0005599 NA 36 30 1.013253 -0.2275888
## 6: %Air sec 0.0465 0.0005599 NA 36 30 1.013253 -0.2175776
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -373.0205 NA mgO2/hr/kg -373.0205
## 2: -407.3460 NA mgO2/hr/kg -407.3460
## 3: -441.0046 NA mgO2/hr/kg -441.0046
## 4: -364.6753 NA mgO2/hr/kg -364.6753
## 5: -406.4811 NA mgO2/hr/kg -406.4811
## 6: -388.6007 NA mgO2/hr/kg -388.6007
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 4 | CARL344 | CARL370 | Arlington reef | 166 | 0.0005599 | ch1 | Dell | 0.0465 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 403.2906 | 0.2258024 | 0.9938 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.82
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 19 20 21 22 23
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.08 1.36
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 382.3312 -0.05864688 0.9990141 NA 109 162 4938.07
## 2: NA 2 381.7287 -0.05852598 0.9988950 NA 108 161 4936.98
## 3: NA 3 381.6133 -0.05850202 0.9988679 NA 110 163 4939.39
## 4: NA 4 381.1538 -0.05841087 0.9987114 NA 107 160 4935.87
## 5: NA 5 380.4760 -0.05827278 0.9986183 NA 111 164 4940.49
## ---
## 205: NA 205 277.7706 -0.03773117 0.9923443 NA 165 218 5002.83
## 206: NA 206 277.4541 -0.03766613 0.9927429 NA 162 215 4999.31
## 207: NA 207 277.4199 -0.03765931 0.9923148 NA 161 214 4998.22
## 208: NA 208 277.1961 -0.03761533 0.9928797 NA 163 216 5000.40
## 209: NA 209 276.4140 -0.03746106 0.9926921 NA 164 217 5001.73
## endtime oxy endoxy rate
## 1: 4998.07 92.689 89.229 -0.05864688
## 2: 4996.98 92.743 89.326 -0.05852598
## 3: 4999.39 92.660 89.224 -0.05850202
## 4: 4995.87 92.822 89.384 -0.05841087
## 5: 5000.49 92.667 89.193 -0.05827278
## ---
## 205: 5062.83 89.154 86.607 -0.03773117
## 206: 5059.31 89.229 86.886 -0.03766613
## 207: 5058.22 89.326 86.909 -0.03765931
## 208: 5060.40 89.224 86.796 -0.03761533
## 209: 5061.73 89.193 86.683 -0.03746106
##
## Regressions : 209 | Results : 209 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 209 adjusted rate(s):
## Rate : -0.05864688
## Adjustment : -0.001991113
## Adjusted Rate : -0.05665576
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 209 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 208 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 382.3312 -0.05864688 0.9990141 NA 109 162 4938.07
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 4998.07 92.689 89.229 -0.05864688 -0.001991113 -0.05665576 -0.05665576
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0465 0.0005599 NA 36 30 1.013253 -0.5865917
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1047.672 NA mgO2/hr/kg -1047.672
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 4 | CARL344 | CARL370 | Arlington reef | 166 | 0.0005599 | ch1 | Dell | 0.0465 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 403.2906 | 0.2258024 | 0.9938 | 1047.672 | 0.5865917 | 0.9990141 | 644.3816 | 0.3607893 |
## Rows: 247 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 5
mass = 0.0005589
chamber = "ch4"
Swim = "good/good"
chamber_vol = chamber4_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "06 April 2023 12 51PM/Oxygen"
experiment_mmr_date2_asus <- "06 April 2023 12 51PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0001161395
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.003917569
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.52
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 11 13 14 15 16 17 18 19 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.52
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2_asus$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 1 rate(s) removed, 19 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 13 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 4 1 437.8574 -0.02848145 0.991 NA 1235 1424 11910.15
## 2: 5 1 482.6493 -0.03079129 0.975 NA 1593 1701 12450.86
## 3: 9 1 516.3811 -0.02852584 0.987 NA 3073 3260 14609.86
## 4: 13 1 646.7308 -0.03262966 0.992 NA 4669 4858 16770.68
## 5: 18 1 728.4219 -0.03232123 0.958 NA 6665 6854 19470.33
## 6: 20 1 821.4909 -0.03519720 0.999 NA 7465 7654 20550.48
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 12165.35 98.132 90.980 -0.02848145 -0.002342744 -0.02613870 -0.02613870
## 2: 12707.17 98.465 90.767 -0.03079129 -0.002611533 -0.02817975 -0.02817975
## 3: 14864.87 99.261 91.461 -0.02852584 -0.003683357 -0.02484248 -0.02484248
## 4: 17026.29 99.017 91.090 -0.03262966 -0.004756557 -0.02787310 -0.02787310
## 5: 19725.72 98.371 90.132 -0.03232123 -0.006097133 -0.02622410 -0.02622410
## 6: 20805.52 98.048 89.181 -0.03519720 -0.006633443 -0.02856375 -0.02856375
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.05068 0.0005589 NA 36 30 1.013253 -0.2949575
## 2: %Air sec 0.05068 0.0005589 NA 36 30 1.013253 -0.3179894
## 3: %Air sec 0.05068 0.0005589 NA 36 30 1.013253 -0.2803306
## 4: %Air sec 0.05068 0.0005589 NA 36 30 1.013253 -0.3145290
## 5: %Air sec 0.05068 0.0005589 NA 36 30 1.013253 -0.2959212
## 6: %Air sec 0.05068 0.0005589 NA 36 30 1.013253 -0.3223226
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -527.7465 NA mgO2/hr/kg -527.7465
## 2: -568.9558 NA mgO2/hr/kg -568.9558
## 3: -501.5755 NA mgO2/hr/kg -501.5755
## 4: -562.7644 NA mgO2/hr/kg -562.7644
## 5: -529.4707 NA mgO2/hr/kg -529.4707
## 6: -576.7088 NA mgO2/hr/kg -576.7088
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 5 | CARL344 | CARL370 | Arlington reef | 166 | 0.0005589 | ch4 | Asus | 0.05068 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 553.1293 | 0.3091439 | 0.983 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 4.98
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 9 10 11 12 14 15 16 19 20 21 22 23 24
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.43
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 633.5467 -0.07432025 0.9940694 NA 49 94 7223.49
## 2: NA 2 633.4348 -0.07430611 0.9940322 NA 48 93 7222.14
## 3: NA 3 633.3883 -0.07430318 0.9940135 NA 44 89 7216.73
## 4: NA 4 632.8670 -0.07422884 0.9938658 NA 47 92 7220.81
## 5: NA 5 632.8402 -0.07422182 0.9938566 NA 50 95 7224.85
## ---
## 174: NA 174 366.2027 -0.03789135 0.9911963 NA 161 206 7374.92
## 175: NA 175 366.1858 -0.03789033 0.9909646 NA 166 211 7381.66
## 176: NA 176 366.1620 -0.03788635 0.9911579 NA 163 208 7377.60
## 177: NA 177 365.7651 -0.03783288 0.9911722 NA 164 209 7378.93
## 178: NA 178 365.1736 -0.03775335 0.9913158 NA 165 210 7380.30
## endtime oxy endoxy rate
## 1: 7283.49 96.533 92.438 -0.07432025
## 2: 7282.14 96.650 92.476 -0.07430611
## 3: 7276.73 97.019 92.820 -0.07430318
## 4: 7280.81 96.793 92.535 -0.07422884
## 5: 7284.85 96.504 92.333 -0.07422182
## ---
## 174: 7434.92 86.939 84.394 -0.03789135
## 175: 7441.66 86.563 84.124 -0.03789033
## 176: 7437.60 86.729 84.361 -0.03788635
## 177: 7438.93 86.664 84.324 -0.03783288
## 178: 7440.30 86.649 84.245 -0.03775335
##
## Regressions : 178 | Results : 178 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 178 adjusted rate(s):
## Rate : -0.07432025
## Adjustment : -0.0001161395
## Adjusted Rate : -0.07420411
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 178 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 177 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 633.5467 -0.07432025 0.9940694 NA 49 94 7223.49
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 7283.49 96.533 92.438 -0.07432025 -0.0001161395 -0.07420411 -0.07420411
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.05068 0.0005589 NA 36 30 1.013253 -0.8373431
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1498.198 NA mgO2/hr/kg -1498.198
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 5 | CARL344 | CARL370 | Arlington reef | 166 | 0.0005589 | ch4 | Asus | 0.05068 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 553.1293 | 0.3091439 | 0.983 | 1498.198 | 0.8373431 | 0.9940694 | 945.0691 | 0.5281991 | ||
| ### Expor | ting data |
## Rows: 248 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 6
mass = 0.0004175
chamber = "ch3"
Swim = "good/good"
chamber_vol = chamber3_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "06 April 2023 01 02PM/Oxygen"
experiment_mmr_date2_asus <- "06 April 2023 01 02PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0009748447
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.005326622
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.52
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 11 13 14 15 16 17 18 19 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.52
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 20 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 14 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 6 1 272.6822 -0.01340579 0.976 NA 1874 2056 12990.28
## 2: 8 1 302.3918 -0.01446341 0.994 NA 2674 2856 14070.79
## 3: 13 1 353.8489 -0.01517080 0.986 NA 4669 4850 16770.68
## 4: 15 1 399.5058 -0.01680641 0.995 NA 5467 5648 17850.10
## 5: 16 1 397.2510 -0.01619954 0.995 NA 5866 6047 18389.77
## 6: 19 1 446.4899 -0.01741854 0.981 NA 7065 7247 20010.55
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 13235.93 98.945 95.157 -0.01340579 -0.004135130 -0.009270655 -0.009270655
## 2: 14316.55 98.952 95.270 -0.01446341 -0.004749419 -0.009713991 -0.009713991
## 3: 17015.49 99.244 95.361 -0.01517080 -0.006284005 -0.008886796 -0.008886796
## 4: 18094.85 99.401 95.195 -0.01680641 -0.006897625 -0.009908787 -0.009908787
## 5: 18634.46 99.390 95.239 -0.01619954 -0.007204404 -0.008995141 -0.008995141
## 6: 20256.16 98.202 93.494 -0.01741854 -0.008126060 -0.009292478 -0.009292478
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04873 0.0004175 NA 36 30 1.013253 -0.10058788
## 2: %Air sec 0.04873 0.0004175 NA 36 30 1.013253 -0.10539814
## 3: %Air sec 0.04873 0.0004175 NA 36 30 1.013253 -0.09642296
## 4: %Air sec 0.04873 0.0004175 NA 36 30 1.013253 -0.10751170
## 5: %Air sec 0.04873 0.0004175 NA 36 30 1.013253 -0.09759852
## 6: %Air sec 0.04873 0.0004175 NA 36 30 1.013253 -0.10082467
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -240.9291 NA mgO2/hr/kg -240.9291
## 2: -252.4506 NA mgO2/hr/kg -252.4506
## 3: -230.9532 NA mgO2/hr/kg -230.9532
## 4: -257.5131 NA mgO2/hr/kg -257.5131
## 5: -233.7689 NA mgO2/hr/kg -233.7689
## 6: -241.4962 NA mgO2/hr/kg -241.4962
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 6 | CARL344 | CARL370 | Arlington reef | 166 | 0.0004175 | ch3 | Asus | 0.04873 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 245.2316 | 0.1023842 | 0.9882 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 4.98
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 3 4 5 6 8 9 10 11 13 14 15 16 18 19 20 21 22 23 24
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.41
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 662.7767 -0.07123913 0.9847744 NA 112 157 7975.87
## 2: NA 2 661.5763 -0.07108899 0.9846402 NA 113 158 7977.25
## 3: NA 3 661.0087 -0.07101881 0.9844114 NA 111 156 7974.51
## 4: NA 4 659.5828 -0.07084003 0.9845234 NA 114 159 7978.60
## 5: NA 5 658.2592 -0.07067616 0.9835855 NA 110 155 7973.18
## ---
## 173: NA 173 326.8444 -0.02948299 0.9700225 NA 169 214 8053.00
## 174: NA 174 329.4883 -0.02947602 0.9731954 NA 75 120 7925.77
## 175: NA 175 328.1991 -0.02931227 0.9745963 NA 72 117 7921.72
## 176: NA 176 327.8286 -0.02926669 0.9747328 NA 74 119 7924.43
## 177: NA 177 326.9843 -0.02916001 0.9753127 NA 73 118 7923.08
## endtime oxy endoxy rate
## 1: 8035.87 94.496 90.356 -0.07123913
## 2: 8037.25 94.544 90.287 -0.07108899
## 3: 8034.51 94.492 90.486 -0.07101881
## 4: 8038.60 94.499 90.186 -0.07084003
## 5: 8033.18 94.508 90.609 -0.07067616
## ---
## 173: 8113.00 89.556 87.625 -0.02948299
## 174: 7985.77 95.968 93.932 -0.02947602
## 175: 7981.72 96.129 94.252 -0.02931227
## 176: 7984.43 96.003 94.032 -0.02926669
## 177: 7983.08 96.094 94.146 -0.02916001
##
## Regressions : 177 | Results : 177 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 177 adjusted rate(s):
## Rate : -0.07123913
## Adjustment : -0.0009748447
## Adjusted Rate : -0.07026428
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 12 rate(s) removed, 165 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 164 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 662.7767 -0.07123913 0.9847744 NA 112 157 7975.87
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 8035.87 94.496 90.356 -0.07123913 -0.0009748447 -0.07026428 -0.07026428
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04873 0.0004175 NA 36 30 1.013253 -0.7623772
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1826.053 NA mgO2/hr/kg -1826.053
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 6 | CARL344 | CARL370 | Arlington reef | 166 | 0.0004175 | ch3 | Asus | 0.04873 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 245.2316 | 0.1023842 | 0.9882 | 1826.053 | 0.7623772 | 0.9847744 | 1580.821 | 0.659993 | ||
| ### Expor | ting data |
## Rows: 249 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 7
mass = 0.0007854
chamber = "ch2"
Swim = "good/good"
chamber_vol = chamber2_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "06 April 2023 01 21PM/Oxygen"
experiment_mmr_date2_asus <- "06 April 2023 01 21PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.001190619
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0053072
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.52
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 11 13 14 15 16 17 18 19 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.52
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 20 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 14 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 7 1 572.6991 -0.03510095 0.996 NA 2274 2456 13530.41
## 2: 12 1 717.4877 -0.03818413 0.993 NA 4269 4451 16229.82
## 3: 13 1 724.8877 -0.03738925 0.989 NA 4669 4850 16770.68
## 4: 14 1 746.2465 -0.03743571 0.986 NA 5068 5249 17310.38
## 5: 15 1 775.5455 -0.03792504 0.983 NA 5467 5648 17850.10
## 6: 16 1 665.5923 -0.03084318 0.991 NA 5866 6047 18389.77
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 13776.29 97.782 89.393 -0.03510095 -0.004470628 -0.03063032 -0.03063032
## 2: 16475.95 98.174 88.082 -0.03818413 -0.005922339 -0.03226179 -0.03226179
## 3: 17015.49 98.018 89.331 -0.03738925 -0.006212839 -0.03117641 -0.03117641
## 4: 17555.08 98.158 89.457 -0.03743571 -0.006503041 -0.03093267 -0.03093267
## 5: 18094.85 98.312 89.901 -0.03792504 -0.006793296 -0.03113175 -0.03113175
## 6: 18634.46 98.389 90.465 -0.03084318 -0.007083495 -0.02375969 -0.02375969
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04958 0.0007854 NA 36 30 1.013253 -0.3381402
## 2: %Air sec 0.04958 0.0007854 NA 36 30 1.013253 -0.3561507
## 3: %Air sec 0.04958 0.0007854 NA 36 30 1.013253 -0.3441687
## 4: %Air sec 0.04958 0.0007854 NA 36 30 1.013253 -0.3414781
## 5: %Air sec 0.04958 0.0007854 NA 36 30 1.013253 -0.3436757
## 6: %Air sec 0.04958 0.0007854 NA 36 30 1.013253 -0.2622926
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -430.5325 NA mgO2/hr/kg -430.5325
## 2: -453.4641 NA mgO2/hr/kg -453.4641
## 3: -438.2082 NA mgO2/hr/kg -438.2082
## 4: -434.7824 NA mgO2/hr/kg -434.7824
## 5: -437.5805 NA mgO2/hr/kg -437.5805
## 6: -333.9606 NA mgO2/hr/kg -333.9606
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 7 | CARL344 | CARL370 | Arlington reef | 166 | 0.0007854 | ch2 | Asus | 0.04958 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 438.9136 | 0.3447227 | 0.9894 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 4.98
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 8 10 11 12 13 14 15 16 17 18 19 20 21 23
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.41
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 881.9030 -0.08684066 0.9976450 NA 14 59 9027.68
## 2: NA 2 881.2432 -0.08676840 0.9975659 NA 13 58 9026.34
## 3: NA 3 880.4608 -0.08668075 0.9974337 NA 15 60 9029.01
## 4: NA 4 879.9748 -0.08662883 0.9974375 NA 12 57 9025.00
## 5: NA 5 877.4307 -0.08634834 0.9971817 NA 11 56 9023.64
## ---
## 174: NA 174 450.0139 -0.03962721 0.9403317 NA 142 187 9200.66
## 175: NA 175 449.7562 -0.03959538 0.9410714 NA 138 183 9195.22
## 176: NA 176 447.3129 -0.03933347 0.9420464 NA 141 186 9199.29
## 177: NA 177 446.9399 -0.03929100 0.9423044 NA 139 184 9196.56
## 178: NA 178 446.3632 -0.03922948 0.9426199 NA 140 185 9197.93
## endtime oxy endoxy rate
## 1: 9087.68 97.858 92.825 -0.08684066
## 2: 9086.34 97.972 92.903 -0.08676840
## 3: 9089.01 97.775 92.794 -0.08668075
## 4: 9085.00 98.048 92.987 -0.08662883
## 5: 9083.64 98.147 93.062 -0.08634834
## ---
## 174: 9260.66 85.616 82.749 -0.03962721
## 175: 9255.22 85.925 83.191 -0.03959538
## 176: 9259.29 85.706 82.873 -0.03933347
## 177: 9256.56 85.886 83.128 -0.03929100
## 178: 9257.93 85.787 82.993 -0.03922948
##
## Regressions : 178 | Results : 178 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 178 adjusted rate(s):
## Rate : -0.08684066
## Adjustment : -0.001190619
## Adjusted Rate : -0.08565004
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 11 rate(s) removed, 167 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 166 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 881.903 -0.08684066 0.997645 NA 14 59 9027.68
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 9087.68 97.858 92.825 -0.08684066 -0.001190619 -0.08565004 -0.08565004
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04958 0.0007854 NA 36 30 1.013253 -0.9455249
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1203.877 NA mgO2/hr/kg -1203.877
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 7 | CARL344 | CARL370 | Arlington reef | 166 | 0.0007854 | ch2 | Asus | 0.04958 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 438.9136 | 0.3447227 | 0.9894 | 1203.877 | 0.9455249 | 0.997645 | 764.9633 | 0.6008021 | ||
| ### Expor | ting data |
## Rows: 250 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 8
mass = 0.0004987
chamber = "ch1"
Swim = "good/good"
chamber_vol = chamber1_asus
system1 = "Asus"
Notes="check max"
##--- time of trail ---##
experiment_mmr_date_asus <- "06 April 2023 01 42PM/Oxygen"
experiment_mmr_date2_asus <- "06 April 2023 01 42PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.000672184
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0005015504
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.52
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 11 13 14 15 16 17 18 19 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.52
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## Warning: adjust_rate: background rates in 'by' and 'by2' differ in sign (i.e. one is +ve, one is -ve).
## Ensure this is correct. The 'linear' adjustment has been performed regardless.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 20 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 14 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 9 1 396.9579 -0.02057173 0.986 NA 3073 3254 14609.86
## 2: 10 1 437.7118 -0.02251635 0.984 NA 3471 3652 15150.00
## 3: 11 1 457.0113 -0.02302550 0.989 NA 3870 4051 15689.93
## 4: 13 1 448.1606 -0.02098285 0.990 NA 4669 4850 16770.68
## 5: 14 1 432.6989 -0.01943280 0.992 NA 5068 5249 17310.38
## 6: 15 1 487.9691 -0.02194276 0.990 NA 5467 5648 17850.10
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 14856.75 95.887 91.081 -0.02057173 0.0004286125 -0.02100034 -0.02100034
## 2: 15395.04 96.213 90.775 -0.02251635 0.0005112898 -0.02302764 -0.02302764
## 3: 15934.90 95.507 89.833 -0.02302550 0.0005940715 -0.02361957 -0.02361957
## 4: 17015.49 96.307 90.834 -0.02098285 0.0007597696 -0.02174262 -0.02174262
## 5: 17555.08 95.999 91.331 -0.01943280 0.0008425129 -0.02027531 -0.02027531
## 6: 18094.85 96.067 90.650 -0.02194276 0.0009252715 -0.02286803 -0.02286803
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04565 0.0004987 NA 36 30 1.013253 -0.2134548
## 2: %Air sec 0.04565 0.0004987 NA 36 30 1.013253 -0.2340610
## 3: %Air sec 0.04565 0.0004987 NA 36 30 1.013253 -0.2400776
## 4: %Air sec 0.04565 0.0004987 NA 36 30 1.013253 -0.2209996
## 5: %Air sec 0.04565 0.0004987 NA 36 30 1.013253 -0.2060854
## 6: %Air sec 0.04565 0.0004987 NA 36 30 1.013253 -0.2324387
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -428.0225 NA mgO2/hr/kg -428.0225
## 2: -469.3423 NA mgO2/hr/kg -469.3423
## 3: -481.4069 NA mgO2/hr/kg -481.4069
## 4: -443.1514 NA mgO2/hr/kg -443.1514
## 5: -413.2452 NA mgO2/hr/kg -413.2452
## 6: -466.0892 NA mgO2/hr/kg -466.0892
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 8 | CARL344 | CARL370 | Arlington reef | 166 | 0.0004987 | ch1 | Asus | 0.04565 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 457.6025 | 0.2282064 | 0.9878 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.52
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 11 13 14 15 16 17 18 19 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.40
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 647.0437 -0.05346365 0.9970411 NA 106 151 10387.92
## 2: NA 2 646.0497 -0.05336782 0.9968099 NA 107 152 10389.28
## 3: NA 3 644.8061 -0.05324944 0.9963548 NA 105 150 10386.56
## 4: NA 4 643.8301 -0.05315453 0.9964526 NA 108 153 10390.63
## 5: NA 5 641.8377 -0.05296282 0.9960540 NA 110 155 10393.30
## ---
## 174: NA 174 452.5722 -0.03467478 0.9584826 NA 5 50 10251.65
## 175: NA 175 444.6375 -0.03390283 0.9585291 NA 4 49 10250.32
## 176: NA 176 435.2708 -0.03299138 0.9597737 NA 3 48 10248.99
## 177: NA 177 427.0719 -0.03219358 0.9593406 NA 2 47 10247.65
## 178: NA 178 419.4660 -0.03145345 0.9581565 NA 1 46 10246.29
## endtime oxy endoxy rate
## 1: 10447.92 91.517 88.545 -0.05346365
## 2: 10449.28 91.556 88.513 -0.05336782
## 3: 10446.56 91.557 88.593 -0.05324944
## 4: 10450.63 91.543 88.443 -0.05315453
## 5: 10453.30 91.376 88.240 -0.05296282
## ---
## 174: 10311.65 96.980 94.809 -0.03467478
## 175: 10310.32 96.993 94.828 -0.03390283
## 176: 10308.99 97.003 94.962 -0.03299138
## 177: 10307.65 97.020 95.060 -0.03219358
## 178: 10306.29 97.090 95.101 -0.03145345
##
## Regressions : 178 | Results : 178 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 178 adjusted rate(s):
## Rate : -0.05346365
## Adjustment : -0.000672184
## Adjusted Rate : -0.05279147
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 178 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 177 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 647.0437 -0.05346365 0.9970411 NA 106 151 10387.92
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 10447.92 91.517 88.545 -0.05346365 -0.000672184 -0.05279147 -0.05279147
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04565 0.0004987 NA 36 30 1.013253 -0.536591
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1075.98 NA mgO2/hr/kg -1075.98
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 8 | CARL344 | CARL370 | Arlington reef | 166 | 0.0004987 | ch1 | Asus | 0.04565 | 2023-04-06 | 2024-06-26 | good/good | 36 | 30 | 457.6025 | 0.2282064 | 0.9878 | 1075.98 | 0.536591 | 0.9970411 | 618.3771 | 0.3083846 | check max | |
| ### Expor | ting data |
## Rows: 251 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.